//
//  AppDelegate.m
//  ChinaPoem
//
//  Created by 赵俊明 on 2019/3/4.
//  Copyright © 2019 赵俊明. All rights reserved.
//

#import "AppDelegate.h"
#import "CPNavController.h"
#import "CPSETController.h"
#import "CPHomeViewController.h"
#import "MMDrawerController.h"
#import "UIViewController+MMDrawerController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window.backgroundColor = [UIColor whiteColor];
    NSFileManager *manger = [NSFileManager defaultManager];
    NSString *sqlPath = [JMDocumentsPath stringByAppendingPathComponent:@"ChinaPoem.sqlite"];
    if (![manger fileExistsAtPath:sqlPath]) {
        NSString *sqlString = [[NSBundle mainBundle] pathForResource:@"ChinaPoem" ofType:@"sqlite"];
        [manger copyItemAtPath:sqlString toPath:sqlPath error:nil];
    }
    UIViewController *cp_VC = [[CPHomeViewController alloc] init];
    UIViewController *set_VC = [[CPSETController alloc] init];
    CPNavController *nav = [[CPNavController alloc] initWithRootViewController:cp_VC];
    MMDrawerController * dController = [[MMDrawerController alloc] initWithCenterViewController:nav leftDrawerViewController:set_VC];
    dController.maximumLeftDrawerWidth = kW*0.618;
    dController.openDrawerGestureModeMask = MMOpenDrawerGestureModeNone;
    dController.closeDrawerGestureModeMask = MMCloseDrawerGestureModeAll;
    self.window.rootViewController = dController;
    [self.window makeKeyAndVisible];
    return YES;
}

@end
